#ifndef CTERRAIN_H__
#define CTERRAIN_H__
#include <d3d9.h>
#include <d3dx9.h>

#include "IRenderable.h"
#include "..\\GameCore\\CCore.h"
#include "..\\Util\\Common.h"
#include "CBaseMesh.h"
#include <boost/thread.hpp>

namespace Content
{

class CTerrain : public IRenderable
{
public:
	CTerrain();
	~CTerrain();
	void init();
  void render();
	void clean();
	void onLostDevice();
	void onResetDevice();
	boost::mutex* getMutex();


private:
	LPDIRECT3DVERTEXBUFFER9 v_buffer;    // the pointer to the vertex buffer
	LPDIRECT3DINDEXBUFFER9 i_buffer;    // the pointer to the index buffer
	LPDIRECT3DDEVICE9 pD3DDevice;
	LPDIRECT3DTEXTURE9 pTexture;
	LPD3DXEFFECT pEffect;
	LPDIRECT3DVERTEXDECLARATION9 pVertexDecl;

	boost::mutex mut;
	D3DXHANDLE   hTech;
	D3DXHANDLE   hWVP;
	D3DXHANDLE   hWorld;
	D3DXHANDLE  hAmbientMaterialColor;
	D3DXHANDLE  hDiffuseMaterialColor;
	D3DXHANDLE  hSpecularMaterialColor;
	D3DXHANDLE 	hLightColor;
	D3DXHANDLE 	hLightPos;
	D3DXHANDLE 	hSpecularPower;
	D3DXHANDLE 	hCameraPos;
	D3DXHANDLE 	hTex0;

	D3DXHANDLE 	hDT;

	
	D3DXCOLOR ambientMat;
	D3DXCOLOR diffuseMat;
	D3DXCOLOR specularMat;
	float specularPower;
	

	D3DXCOLOR lightColor;
	D3DXVECTOR3 lightPos;

	
	int height, width;

  void initVertexBuffer(void);
	void initTexture(void);
	void initVertexDecl(void);
	void initFX(void);


};

}//namespace Content

#endif 